package com.twoGroup.boot.service.imp;


import com.twoGroup.boot.mapper.LikeMapper;
import com.twoGroup.boot.pojo.LikeAndGoods;
import com.twoGroup.boot.service.LikeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class LikeServiceImpl implements LikeService {
    @Autowired
    private LikeMapper likeMapper;


    @Override
    public Integer addUserLike(Integer userId, Integer goodsId, Integer shopId) {
        if(likeMapper.selectLikeCount(userId, goodsId)==0){
            return likeMapper.addUserLike(userId, goodsId, shopId);
        }else{
            return 0;
        }
    }

    @Override
    public Integer deleteLike(Integer likeId) {
        return likeMapper.deleteLike(likeId);
    }

    @Override
    public Integer deleteAllLike(Integer userId) {
        return likeMapper.deleteAllLike(userId);
    }

    @Override
    public Integer selectLikeCount(Integer userId, Integer goodsId) {
        return likeMapper.selectLikeCount(userId, goodsId);
    }

    @Override
    public List<LikeAndGoods> selectAllLike(Integer userId) {
        return likeMapper.selectAllLike(userId);
    }

    @Override
    public Integer selectCount(Integer userId) {
        return likeMapper.selectCount(userId);
    }
}
